package demo.DataStrucAndAlgo.Easy_pritice;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/15-10-15-19:51
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class JingDongTest3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        long[] counts = new long[3];             //0-->r ,   1--> e ,2--> d,
        long wen = 0;
        for (int i = 0; i < str.length(); i++) {
            int index = 0;
            if(str.charAt(i) == 'r'){
                index = 0;
            }else if(str.charAt(i) == 'e'){
                index = 1;
            }else if(str.charAt(i) == 'd'){
                index = 2;
            }else {
                wen++;
                wen = wen % 1000000007;
                continue;
            }
            counts[index]++;
            counts[index] = counts[index] % 1000000007;
        }
        Arrays.sort(counts);
        while (wen >= 0){
            if(counts[1] > counts[0]){
                long temp = counts[1]-counts[0];
                long value = Math.min(temp, wen);
                wen = wen - value;
                counts[0] = counts[0] + value;
            }else{
                if(counts[2] == counts[1]){
                    for (int i = 0; i < 3; i++) {
                        counts[i] = counts[i] + wen/3;
                        wen = -1;
                    }
                }else{
                    long temp = counts[2] - counts[1];
                    if(temp*2 < wen ){
                        counts[0] = counts[0] + temp;
                        counts[1] = counts[1] + temp;
                        wen = wen - temp * 2;
                    }else{
                        counts[0] = counts[0] + wen/2;
                        counts[1] = counts[1] + wen/2;
                        wen = -1;
                    }
                }
            }
        }
        System.out.println(counts[0] % 1000000007);
    }
}
